import { history } from '@umijs/max';
import {
  Button,
  Grid,
  Popover,
  Space,
  Swiper,
  Switch,
  Toast,
} from 'antd-mobile';
import { getQueryParams } from '../../utils.js'
import { useEffect, useRef, useState } from 'react';
import styles from './index.less';

export default function IndexPage() {
  const handler = useRef()
  const [comment, setComment] = useState('')

  const fetchData = () => {
    const url = location.href;
    const { api_key } = getQueryParams(url)
    const local_api_key = window.localStorage.getItem('api_key')
    if (!api_key && !local_api_key) {
      return Toast.show({
        icon: 'fail',
        content: '请扫码获取权限',
      })
    }
    if (api_key && local_api_key !== api_key) {
      window.localStorage.setItem('api_key', api_key)
    }
    handler.current = Toast.show({
      icon: 'loading',
      content: '加载中…',
      maskClickable: false,
      duration: 0,
    })
    const key = api_key || local_api_key
  }

  useEffect(() => {
    fetchData()
  }, [])

  return (
    <div className={styles.homeWarp}>

    </div>
  );
}
